Skip to content

Improve handling of user interaction on the Github App and the polling bot - #6

Merged
okotek merged 3 commits into
mainfrom
feature/github_tag_improve
Jul 6, 2023
Merged

okotek merged 3 commits into
mainfrom
feature/github_tag_improve

Conversation

@okotek

@okotek okotek commented Jul 6, 2023 •

Copy link
Copy Markdown
Contributor

No description provided.

@okotek
okotek merged commit a2d8695 into main Jul 6, 2023
@okotek
okotek deleted the feature/github_tag_improve branch July 6, 2023 10:24
@okotek
okotek restored the feature/github_tag_improve branch January 7, 2024 11:50
yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
…mprove

Improve handling of user interaction on the Github App and the polling bot
mrT23 pushed a commit that referenced this pull request May 25, 2025
refactor: reorder and clarify describe tool docs, enforce opt-in default for add_diagram
agonzalesipcoop-cmyk pushed a commit to agonzalesipcoop-cmyk/pr-agent that referenced this pull request May 8, 2026
…view

- Extract loader into pr_agent/algo/best_practices.py and reuse it from
  /improve and /review so OSS behavior is symmetric (closes Qodo The-PR-Agent#1).
- Guard int(max_lines_allowed) with TypeError/ValueError fallback to 800
  plus a targeted warning (Qodo The-PR-Agent#2).
- Bitbucket get_pr_agent_repo_custom_file: only accept HTTP 200, log
  non-404 failures, add 10s timeout, and use the repo default branch
  via get_repo_default_branch (Qodo The-PR-Agent#3, The-PR-Agent#5, The-PR-Agent#6).
- LocalGitProvider get_pr_agent_repo_custom_file: resolve and verify the
  candidate path stays inside the repo root before reading (Qodo The-PR-Agent#7).
- Soften prompt wording in code-suggestions templates and add a parallel
  block in pr_reviewer_prompts.toml so the model treats the section as
  guidance, ignoring obvious non-guideline content.
- Drop unused _FakeContext test helper, retarget patches to the new
  module, add coverage for the invalid max_lines fallback (Qodo The-PR-Agent#4).
- Update docs/improve.md and docs/review.md to reflect that both tools
  now consume best_practices.md in OSS.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dellch dellch mentioned this pull request Jun 2, 2026
3 tasks done
Oxygen56 added a commit to Oxygen56/pr-agent that referenced this pull request Jun 8, 2026
- Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN,
  _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of
  inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6).
- Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper
  case-insensitive matching.
- Replace substring match ('app.asana.com' in ticket) with
  prefix check (ticket.startswith()) to fix CodeQL URL
  sanitization warning (comment The-PR-Agent#4).
- Reserve at least one slot for Asana tickets during
  truncation when there are 3+ GitHub/branch tickets
  (comment The-PR-Agent#8).
- Dedent only actual leading whitespace instead of blindly
  slicing dline[remove_count:] to avoid deleting real code
  on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9).
- Remove unused 'import pytest' from test file
  (comments The-PR-Agent#10/The-PR-Agent#20).
- Add test_shorthand_mixed_case_asana and
  test_shorthand_respects_word_boundary test cases.
Oxygen56 added a commit to Oxygen56/pr-agent that referenced this pull request Jun 8, 2026
- Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN,
  _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of
  inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6).
- Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper
  case-insensitive matching.
- Replace substring match ('app.asana.com' in ticket) with
  prefix check (ticket.startswith()) to fix CodeQL URL
  sanitization warning (comment The-PR-Agent#4).
- Reserve at least one slot for Asana tickets during
  truncation when there are 3+ GitHub/branch tickets
  (comment The-PR-Agent#8).
- Dedent only actual leading whitespace instead of blindly
  slicing dline[remove_count:] to avoid deleting real code
  on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9).
- Remove unused 'import pytest' from test file
  (comments The-PR-Agent#10/The-PR-Agent#20).
- Add test_shorthand_mixed_case_asana and
  test_shorthand_respects_word_boundary test cases.
ashearin added a commit to ashearin/pr-agent that referenced this pull request Jun 29, 2026
…h failures via typed exception

Addresses Qodo review items The-PR-Agent#2, The-PR-Agent#3, The-PR-Agent#4 on PR The-PR-Agent#2483.

The-PR-Agent#2 Hardcoded managed_default label set
- Add is_describe_managed_label() and _describe_managed_label_names() in
  pr_agent.algo.utils as the single source of truth for the
  /describe-managed namespace.
- Rewrite get_user_labels() to defer to the same helper so the inclusion
  and exclusion rules can never drift.

The-PR-Agent#3 Default label not managed (Bug fix with tests)
- When enable_custom_labels=True and no custom_labels are configured,
  set_custom_labels injects defaults that include 'Bug fix with tests'.
  is_describe_managed_label now classifies that label as managed so
  /describe can remove it once it is no longer recommended.
- This also fixes a pre-existing bug in get_user_labels where
  'Bug fix with tests' was misclassified as a user label.

The-PR-Agent#4 Refresh failure misreported
- Add LabelRefreshError in pr_agent.git_providers.git_provider so
  callers can distinguish a refresh failure from a genuine no-op.
- GitProvider.publish_managed_labels (default impl) and
  GitLabProvider.publish_managed_labels now raise LabelRefreshError on
  pre-write refresh failure instead of returning None.
- PRDescription._safe_publish_labels and PRReviewer.set_review_labels
  catch LabelRefreshError specifically and log a warning that names the
  failure, instead of mis-logging it as 'labels unchanged' /
  'already set'.

#1, The-PR-Agent#5, The-PR-Agent#6, The-PR-Agent#7 from Qodo's review are already addressed in earlier
commits on this branch (36ec454, a7a8cad); Qodo's review listing is
pinned to PR-level diff hunks so they appear in the report against
older revisions.

Tests:
- New TestDescribeManagedLabelNamespace locks the predicate behavior:
  default-set always managed, Bug fix with tests managed under the
  custom-labels default-injection path, and is_describe_managed_label /
  get_user_labels stay disjoint.
- TestSafePublishLabels gains test_predicate_includes_bug_fix_with_tests_when_custom_labels_default
  and test_logs_distinctly_on_refresh_failure.
- test_pr_reviewer_core gains test_set_review_labels_logs_distinctly_on_refresh_failure.
- test_publish_managed_labels_aborts_when_refresh_fails replaced with
  test_publish_managed_labels_raises_when_refresh_fails.
- Full unit suite: 1066 passed, 1 skipped, 3 xfailed (was 1060).

Signed-off-by: Allen Shearin <allen.p.shearin@gmail.com>
naorpeled referenced this pull request in utsab345/pr-agent Jul 3, 2026
…in restricted mode

Address Qodo review on The-PR-Agent#2491:

- #4 (skip path drops changelog output): when a changelog push is requested but not
  possible — provider lacks push support, or restricted_mode disables push_code — the
  tool no longer returns early with only an error. It now still generates the changelog
  and publishes it as a comment (which only needs pull-requests: write), with a note that
  the changes were not pushed. commit_changelog is set to False in that case.
- #5 (skip path still initializes): removes the special early-return init path; the normal
  flow builds only what's needed to generate the changelog.
- #6 (contents default note misleading): clarify that unlisted scopes default to none only
  within an explicit permissions: block; without one, defaults follow repo/org settings.

Update the "no push support" test to assert the comment fallback, and add a restricted_mode
test (push API present but is_supported('push_code') False) asserting it comments, not pushes.
naorpeled added a commit that referenced this pull request Jul 3, 2026
* fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests

- Cache key is now 'related_tickets_<md5(pr_url)>' instead of global
  'related_tickets', preventing stale tickets leaking between unrelated PRs
- Added cache_tickets=true config flag under [pr_reviewer] to allow disabling
- Fixed Dynaconf merge_enabled=True list append bug in both production code
  (env_bridge.py uses case-insensitive pop before set) and test helpers
  (restore_settings now calls _remove_key before every set)
- Added azure-identity dependency for Azure DevOps provider availability
- 1043 tests pass, 0 failures

* Revert "fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests"

This reverts commit 7f0d154.

* feat: add restricted mode for reduced GitHub permissions (#2279)

Add a `config.restricted_mode` option that gates operations requiring
elevated permissions (e.g. pushing code to the repository). When enabled,
`is_supported("push_code")` returns `False` on GitHub, GitLab, and
Bitbucket providers, and `/update_changelog --push_changelog_changes=true`
gracefully skips with a clear message instead of failing.

Users can set `restricted_mode = true` and use only `issues: write`
and `pull-requests: write` permissions, without `contents: write`.

* docs: document restricted_mode for reduced GitHub permissions

* docs: clarify minimal permissions for restricted mode

* fix: move restricted-mode check to __init__ to avoid unnecessary provider reads

PRUpdateChangelog.__init__() was fetching languages, files, and
CHANGELOG.md content before run() checked push_code support.
In restricted mode, these reads were wasted and could fail if
contents access is also restricted.

Move the capability check into __init__() before the expensive
provider calls, and store the result in self._skip_push so
run() can return early.

* fix: remove full-config logging from run() and use mock AI handler in test

- Remove relevant_configs logging that dumps full settings dicts
  (potential secret leak in logs)
- Pass ai_handler mock in test_run_without_push_support to avoid
  instantiating a real LiteLLMAIHandler

* fix: use spec'd mock for push-support test and fix docs permissions note

- Use MagicMock(spec=[...]) in test_run_without_push_support so
  hasattr() correctly returns False for missing attributes instead
  of brittle delattr on bare MagicMock
- Remove misleading 'contents: read (defaults to read)' comment
  from restricted mode docs; contents is simply not needed

* fix: skip __init__ provider reads when _skip_push is set

Move all provider-dependent initialization (vars dict, token handler,
ai_handler binding, language/file/changelog reads) behind the _skip_push
guard so the skip path avoids hitting the git provider at all during
construction.

* fix(update_changelog): degrade to comment instead of dropping output in restricted mode

Address Qodo review on #2491:

- #4 (skip path drops changelog output): when a changelog push is requested but not
  possible — provider lacks push support, or restricted_mode disables push_code — the
  tool no longer returns early with only an error. It now still generates the changelog
  and publishes it as a comment (which only needs pull-requests: write), with a note that
  the changes were not pushed. commit_changelog is set to False in that case.
- #5 (skip path still initializes): removes the special early-return init path; the normal
  flow builds only what's needed to generate the changelog.
- #6 (contents default note misleading): clarify that unlisted scopes default to none only
  within an explicit permissions: block; without one, defaults follow repo/org settings.

Update the "no push support" test to assert the comment fallback, and add a restricted_mode
test (push API present but is_supported('push_code') False) asserting it comments, not pushes.

* fix: generate changelog preview instead of silent skip when push is restricted

When restricted_mode is active and push_changelog_changes=true, the
tool now generates the changelog output via AI and publishes it as a
comment with a '(push restricted by configuration)' label, instead of
returning silently. This ensures users see the changelog even when
they don't have contents: write permissions.

For the 'not supported' case (provider lacks create_or_update_pr_file
entirely), the existing early-return behavior is preserved.

---------

Co-authored-by: Utsab <utsab@pr-agent.dev>
Co-authored-by: naorpeled <me@naor.dev>
@naorpeled
naorpeled deleted the feature/github_tag_improve branch August 29, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants